package com.xinqi.common.base.dto.utils;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

@Data
@Schema(description = "备课区题目汇总-对象")
public class QuestionStats {
    /**
     * 总分
     */
    @Schema(description = "总分", example = "100")
    private BigDecimal totalScore;
    /**
     * 题目总数
     */
    @Schema(description = "题目总数", example = "50")
    private Integer questionTotal;
    /**
     * 题型总数
     */
    @Schema(description = "题型总数", example = "6")
    private Integer questionTypeTotal;
    /**
     * 主观题数量
     */
    @Schema(description = "主观题数量", example = "6")
    private Integer subjectiveQuestionNum;
    /**
     * 客观题数量
     */
    @Schema(description = "客观题数量", example = "6")
    private Integer objectiveQuestionNum;


    public static QuestionStats empty() {
        return of(null, null, null);
    }

    public static QuestionStats of(BigDecimal totalScore, Integer questionTotal, Integer questionTypeTotal) {
        return of(totalScore, questionTotal, questionTypeTotal, null, null);
    }

    public static QuestionStats of(BigDecimal totalScore, Integer questionTotal, Integer questionTypeTotal,
                                   Integer subjectiveQuestionNum, Integer objectiveQuestionNum) {
        QuestionStats questionStats = new QuestionStats();
        questionStats.setTotalScore(totalScore != null ? totalScore : BigDecimal.ZERO);
        questionStats.setQuestionTotal(questionTotal != null ? questionTotal : 0);
        questionStats.setQuestionTypeTotal(questionTypeTotal != null ? questionTypeTotal : 0);
        questionStats.setSubjectiveQuestionNum(subjectiveQuestionNum != null ? subjectiveQuestionNum : 0);
        questionStats.setObjectiveQuestionNum(objectiveQuestionNum != null ? objectiveQuestionNum : 0);
        return questionStats;
    }
}
